Title: SQL W3S (By-BKK) / 118 Injection
Tags: Obsidian_to_Anki

Q: What is SQL injection?
A: SQL injection is a code injection technique that might destroy your database

Q: True or False: SQL injection is a method to optimize SQL queries
A: False

Q: True or False: SQL injection can give hackers access to database data
A: True

Q: SQL injection is the placement of _ code in SQL statements via web page input
A: Malicious

Q: How can SQL injection occur on web pages?
A: It can happen when user input isn't properly checked before being added to SQL statements

Q: Give an example of SQL injection using 'OR 1=1' in a user input
A: A user enters '105 OR 1=1' so the SQL statement returns all rows since OR 1=1 is always true

Q: What risk does 'OR 1=1' pose in SQL queries?
A: It can cause the SQL query to return all data, exposing confidential information

Q: What happens if a login form’s user inputs are used directly in SQL queries?
A: Hackers can manipulate SQL to access or bypass account information

Q: Reverse card:
Returns all rows when manipulated with 'OR ""=""' in SQL query
A: SQL injection using always-true statements

Q: SQL injection can exploit batched SQL statements. True or False?
A: True

Q: What can an attacker do with batched SQL statements in SQL injection?
A: Run multiple commands, such as SELECT and DROP TABLE, harming the database

Q: Reverse card:
Executes multiple queries separated by semicolons in a single input
A: Batched SQL statements in SQL injection

Q: What protection is recommended against SQL injection?
A: Use SQL parameters

Q: What are SQL parameters?
A: Values added to SQL queries at execution time in a controlled, safe way

Q: True or False: SQL parameters are checked by the SQL engine and treated as literal values
A: True

Q: How does an SQL parameter prevent injection?
A: It ensures user input is handled as a value rather than SQL code

Q: Reverse card:
Recommended way to protect web applications from SQL injection
A: Parameterized SQL queries

Q: What does this code do? txtSQL = "SELECT * FROM Users WHERE UserId = @0"; db.Execute(txtSQL, txtUserId);
A: It uses a parameter (@0) to safely add user input, preventing SQL injection

Q: How can you safely insert user input into SQL statements in ASP.NET?
A: By using parameter markers such as @0 and adding values using Parameters.AddWithValue

Q: How can you safely insert user input in SQL statements with PHP?
A: By using prepared statements and binding parameters like :nam, :add, :cit

Q: True or False: Checking user input and using parameterized queries can help prevent SQL injection
A: True

Q: SQL injection is one of the most common web hacking techniques.
A: True

Q: What is the main danger of SQL injection for websites?
A: It can grant hackers access to confidential data and even destroy the database